import request from '@/utils/request';
import { AxiosPromise } from 'axios';

/**
 * 查询仓库管理列表
 * @param query
 * @returns {*}
 */

export const listWarehouse = (query?: WarehouseVO): AxiosPromise<WarehouseVO[]> => {
  return request({
    url: '/wms/warehouse/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询仓库管理详细
 * @param id
 */
export const getWarehouse = (id: string | number): AxiosPromise<WarehouseVO> => {
  return request({
    url: '/wms/warehouse/' + id,
    method: 'get'
  });
};

/**
 * 新增仓库管理
 * @param data
 */
export const addWarehouse = (data: WarehouseVO) => {
  return request({
    url: '/wms/warehouse',
    method: 'post',
    data: data
  });
};

/**
 * 修改仓库管理
 * @param data
 */
export const updateWarehouse = (data: WarehouseVO) => {
  return request({
    url: '/wms/warehouse',
    method: 'put',
    data: data
  });
};

/**
 * 删除仓库管理
 * @param id
 */
export const delWarehouse = (id: string | number | Array<string | number>) => {
  return request({
    url: '/wms/warehouse/' + id,
    method: 'delete'
  });
};

/**
 * 获取仓库产品预警信息
 * @param query
 * @returns {*}
 */
export const getWWPList = (query?: wwpVo): AxiosPromise<wwpVo[]> => {
  return request({
    url: '/wms/warehouse/listWWP',
    method: 'get',
    params: query
  });
};

/**
 * 新增仓仓库产品预警信息
 * @param data
 */
export const addWWP = (data: wwpVo[]) => {
  return request({
    url: '/wms/warehouse/addWWP',
    method: 'post',
    data: data
  });
};


/**
 * 删除仓库产品预警信息
 * @param bo
 */
export const delWWP = (bo: wwpVo) => {
  return request({
    url: '/wms/warehouse/deleteWWP',
    method: 'delete',
    data: bo
  });
};

// /**
//  * 修改仓库产品预警信息
//  * @param data
//  */
// export const updateWWP = (data: wwpVo[]) => {
//   return request({
//     url: '/wms/warehouse/wwp',
//     method: 'put',
//     data: data
//   });
// };

export interface WarehouseVO extends BaseEntity {
  /**
   * 仓库ID
   */
  id?: number;

  /**
   * 库位上级
   */
  parentId?: number;

  /**
   * 仓库名称
   */
  name?: string;

  /**
   * 位置
   */
  location?: string;

  /**
   * 面积
   */
  acreage?: number;

  /**
   * 负责人
   */
  userId?: string | number;

  /**
   * 状态
   */
  status?: string;

  /**
   * 备注
   */
  remark?: string;

  /**
   * 负责人昵称
   */
  userName?: string;

  /**
   * 归属部门
   */
  deptName?: string;

  children?:WarehouseVO [];

}
export interface wwpVo extends BaseEntity,PageQuery {
  /**
   * 仓库ID
   */
  whId?: number;

  /**
   * 产品ID
   */
  productId?: number;

  /**
   * 最低库存
   */
  minStock?: number;

  /**
   * 最高库存
   */
  maxStock?: number;

  /**
   * 存储区域
   */
  areaId?: number;

  /**
   * 存储区域
   */
  productName?: string;
}
